package com.ybe.session;

public class Session {


    final int customerId;
    final String key;
    volatile long expiresAt; // epoch millis

    public int getCustomerId() {
        return customerId;
    }

    public String getKey() {
        return key;
    }

    public long getExpiresAt() {
        return expiresAt;
    }

    public void setExpiresAt(long expiresAt) {
        this.expiresAt = expiresAt;
    }

    public Session(int customerId, String key, long expiresAt) {
        this.customerId = customerId;
        this.key = key;
        this.expiresAt = expiresAt;
    }

    public boolean isExpired(long now) {
        return now >= expiresAt;
    }

    public void refresh(long now) {
        this.expiresAt = now + SessionHolder.SESSION_TTL_MILLIS;
    }


}
